<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <Script Language ="JavaScript">
        function submitClick(){
            var selValue = Select_check("cbx");
            if(selValue == 0){
                alert("你没有做出你喜爱的水果的任何选择，请作出选择！");
                return false;
            }else{
                var selActionValue = Select_check("radio1");
                if(selActionValue == 0){
                    alert("请你做出购买还是不够买的选择！");
                    return false;
                }else{
                    strMsg = "你喜欢的水果有" + selValue;
                    strMsg = strMsg + "，并且你决定了：" + selActionValue;
                    alert(strMsg);
                }
            }
        }
        function Select_check(objName){
            var obj=document.getElementsByName(objName);
            var selArray = new Array();
            for(var i=0;i<obj.length;i++){
                if(obj[i].checked==checked){
                    selArray[i]=obj[i].value;
                }
            }
            return selArray;
        }
    </Script>
</head>
<body>
    <form name="InputForm" method="post" action="">
        你喜欢的水果有？<br>
         <input type=checkbox name=cbx value=苹果>红苹果<br>
         <input type=checkbox name=cbx value=西瓜>大西瓜<br>
         <input type=checkbox name=cbx value=梨子>鲜梨子<br>
         <input type=checkbox name=cbx value=桃子>大桃子<br><br>
        你决定的怎么做？<br>
        <!-- 单选框让type=radio  并且让name属性值一样 -->
         <input type=radio name=radio1 value="Buy">购买上述产品<br>
         <input type=radio name=radio1 value="Nobuy">不购买上述产品<br><br>
         <input type="button" name="Submit" value="提交" onclick=javascript:submitClick()>
         <input type="Reset" name="Reset" value="重置">
    </form>
</body>
</html>